package com.stockz.indicator.util;

import java.util.List;

import com.stockz.core.model.Bar;
import com.stockz.indicator.Indicator;

public class IndicatorUtil {

	public static <T> double[] getValues(Indicator<T> indicator,List<Bar> barList,int span) {
		
		if(barList == null || barList.size() <= span){
			return new double[0];
		}
		
		double[] values = new double[barList.size()];
		for(int i = barList.size()-1; i >=0; i--){
			if(i >= barList.size() - span - 1){
				values[i] = 0;
			}else{
				values[i] = indicator.getValue(barList.subList(i, i+span+1));
			}
		}
		return values;
	}

	
}
